package cn.edu.scau.cmi.wuzewei.comprehensive;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.stage.Stage;


public class ComprehensiveClient extends Application {
	InterProgrammingWindow interProgramming = new InterProgrammingWindow();
	SingletonWindow singleton = new SingletonWindow();
	MultipletonWindow multipleton = new MultipletonWindow();
	SimpleFactoryMethodWindow simpleFactory = new SimpleFactoryMethodWindow();
	FactoryWindow factory = new FactoryWindow();
	AbstractFactoryWindow abstractFactory = new AbstractFactoryWindow();
	AdapterWindow adapter = new AdapterWindow();
	CompositeWindow composite = new CompositeWindow();
	
	@Override
	public void start(Stage primaryStage) throws Exception {
		Group group = new Group();
		
		Image image = new Image("resource/01.jpg");
		ImageView imageView = new ImageView(image);
		imageView.setFitWidth(300);
		imageView.setFitHeight(280);
		imageView.setX(10);
		imageView.setY(10);
		group.getChildren().add(imageView);
		
		Label label1 = new Label("学号： 201625010622");
		label1.setLayoutX(40);
		label1.setLayoutY(300);
		group.getChildren().add(label1);
		
		Label label2 = new Label("姓名： 蔡徐坤");
		label2.setLayoutX(40);
		label2.setLayoutY(320);
		group.getChildren().add(label2);
		
		int x = 350;
		int y = 20;
		Button button1 = new Button("实验一：接口编程");
		button1.setOnAction(new EventHandler<ActionEvent>() {
			@Override
			public void handle(ActionEvent event) {
				Stage stage = new Stage();
				interProgramming.newWindow(stage);
			}
		});
		button1.setLayoutX(x);
		button1.setLayoutY(y);
		group.getChildren().addAll(button1);
		
		Button button2 = new Button("实验二：单例模式");
		button2.setOnAction(new EventHandler<ActionEvent>() {
			@Override
			public void handle(ActionEvent event) {
				Stage stage = new Stage();
				singleton.newWindow(stage);
			}
		});
		button2.setLayoutX(x);
		button2.setLayoutY(y + 30);
		group.getChildren().addAll(button2);
		
		Button button3 = new Button("实验二：多例模式");
		button3.setOnAction(new EventHandler<ActionEvent>() {
			@Override
			public void handle(ActionEvent event) {
				Stage stage = new Stage();
				multipleton.newWindow(stage);
			}
		});
		button3.setLayoutX(x);
		button3.setLayoutY(y + 60);
		group.getChildren().addAll(button3);
		
		Button button4 = new Button("实验三：简单工厂");
		button4.setOnAction(new EventHandler<ActionEvent>() {
			@Override
			public void handle(ActionEvent event) {
				Stage stage = new Stage();
				simpleFactory.newWindow(stage);
			}
		});
		button4.setLayoutX(x);
		button4.setLayoutY(y + 90);
		group.getChildren().addAll(button4);
		
		Button button5 = new Button("实验三：工厂模式");
		button5.setOnAction(new EventHandler<ActionEvent>() {
			@Override
			public void handle(ActionEvent event) {
				Stage stage = new Stage();
				factory.newWindow(stage);
			}
		});
		button5.setLayoutX(x);
		button5.setLayoutY(y + 120);
		group.getChildren().addAll(button5);
		
		Button button6 = new Button("实验三：抽象工厂");
		button6.setOnAction(new EventHandler<ActionEvent>() {
			@Override
			public void handle(ActionEvent event) {
				Stage stage = new Stage();
				abstractFactory.newWindow(stage);
			}
		});
		button6.setLayoutX(x);
		button6.setLayoutY(y + 150);
		group.getChildren().addAll(button6);
		
		Button button7 = new Button("实验四：对象适配器");
		button7.setOnAction(new EventHandler<ActionEvent>() {
			@Override
			public void handle(ActionEvent event) {
				Stage stage = new Stage();
				adapter.newWindow(stage);
			}
		});
		button7.setLayoutX(x);
		button7.setLayoutY(y + 180);
		group.getChildren().addAll(button7);
		
		Button button8 = new Button("实验四：类适配器");
		button8.setOnAction(new EventHandler<ActionEvent>() {
			@Override
			public void handle(ActionEvent event) {
				Stage stage = new Stage();
				adapter.newWindow(stage);
			}
		});
		button8.setLayoutX(x);
		button8.setLayoutY(y + 210);
		group.getChildren().addAll(button8);
		
		Button button9 = new Button("实验五：安全型组合模式");
		button9.setOnAction(new EventHandler<ActionEvent>() {
			@Override
			public void handle(ActionEvent event) {
				Stage stage = new Stage();
				composite.newWindow(stage);
			}
		});
		button9.setLayoutX(x);
		button9.setLayoutY(y + 240);
		group.getChildren().addAll(button9);
		
		Button button10 = new Button("实验五：一致型组合模式");
		button10.setOnAction(new EventHandler<ActionEvent>() {
			@Override
			public void handle(ActionEvent event) {
				Stage stage = new Stage();
				composite.newWindow(stage);
			}
		});
		button10.setLayoutX(x);
		button10.setLayoutY(y + 270);
		group.getChildren().addAll(button10);
		
		Scene scene = new Scene(group);
		primaryStage.setTitle("综合性实验");
		primaryStage.setWidth(530);
		primaryStage.setHeight(400);
		primaryStage.setScene(scene);
		primaryStage.show();
	}

	public static void main(String[] args) {
		launch(args);
	}
}
